<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initAutoLoader()
    {
        $autoloader = Zend_Loader_Autoloader::getInstance();
        $autoloader->setFallbackAutoloader(true);
    }

    protected function _initConfigDatabase()
    {
        $this->bootstrap('db');
        Zend_Db_Table::getDefaultAdapter()->setFetchMode(Zend_Db::FETCH_OBJ);
    }

    protected function _initCacheAdapters()
    {
        $cache = $this->bootstrap('cachemanager')->getContainer()->cachemanager->getCache('default');
        Zend_Translate::setCache($cache);
        Zend_Db_Table::setDefaultMetadataCache($cache);

        // bootstrap cache
        $cacheManager = $this->getResource('cachemanager');
        Zend_Registry::set('Zend_Cache_Manager', $cacheManager);
    }

    protected function _initZFDebug()
    {
return false;
        $autoloader = Zend_Loader_Autoloader::getInstance();
        $autoloader->registerNamespace('ZFDebug');

        $options = array(
            'plugins' => array('Variables',
                               'File' => array('base_path' => '/var/www/cev/'),
                               'Memory',
                               'Time',
                               'Registry',
                               'Exception')
        );

        # Instantiate the database adapter and setup the plugin.
        # Alternatively just add the plugin like above and rely on the autodiscovery feature.
        if ($this->hasPluginResource('db')) {
            $this->bootstrap('db');
            $db = $this->getPluginResource('db')->getDbAdapter();
            $options['plugins']['Database']['adapter'] = $db;
        }

        # Setup the cache plugin
        if ($this->hasPluginResource('cache')) {
            $this->bootstrap('cache');
            $cache = $this-getPluginResource('cache')->getDbAdapter();
            $options['plugins']['Cache']['backend'] = $cache->getBackend();
        }

        $debug = new ZFDebug_Controller_Plugin_Debug($options);

        $this->bootstrap('frontController');
        $frontController = $this->getResource('frontController');
        $frontController->registerPlugin($debug);
    }

    protected function _initCliente()
    {
        return;
        //$cliente = $this->bootstrap('cliente');
        //Zend_Debug::dump($cliente); die;
        Zend_Translate::setCache($cache);
        Zend_Db_Table::setDefaultMetadataCache($cache);

        // bootstrap cache
        $cacheManager = $this->getResource('cachemanager');
        Zend_Registry::set('Zend_Cache_Manager', $cacheManager);
    }
}
